-------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\alony\Dropbox\Alon\@ Research projects @\Peace process opinion\Perceptions of terrorism (with Avishay BSG)\Submissions\2022
> .09 PSRM (accepted)\2023.04 Final version\Data replication files\Replication log - Stata - US.log
  log type:  text
 opened on:  22 May 2023, 00:16:27

. do "C:\Users\alony\AppData\Local\Temp\STDa7b0_000000.tmp"

. ***********************************************************************
. * Is Terrorism Necessarily Violent? Public Perceptions of Nonviolence * 
. * and Terrorism in Conflict Settings                                                              *
. *                                                                     *
. * Avishay Ben Sasson-Gordis & Alon Yakter                                                         *
. * Political Science Research and Methods (2023)                                           *
. *                                                                     *
. * Replication code - US experiment                                                                * *******************************************
> ****************************
. * The analysis was performed with Stata 17.                                               *
. *                                                                                                                                         *
. * To load the data (the "use" command), users should place the .dta       *
. * file in their Stata working directory (or type the full file            *
. * paths as saved on their computer).                                              *
. ***********************************************************************
. 
. **********************************************
. * installing necessary user-written packages *
. **********************************************
. ssc install estout, replace
checking estout consistency and verifying not already installed...
all files already exist and are up to date.

. ssc install grstyle, replace
checking grstyle consistency and verifying not already installed...
all files already exist and are up to date.

. ssc install mplotoffset, replace
checking mplotoffset consistency and verifying not already installed...
all files already exist and are up to date.

. net install grc1leg2.pkg, from (http://digital.cgdev.org/doc/stata/MO/Misc/) replace
checking grc1leg2 consistency and verifying not already installed...

the following files will be replaced:
    c:\ado\plus\g\grc1leg2.ado
    c:\ado\plus\g\grc1leg2.sthlp
    c:\ado\plus\g\grc1leg2_examples.ado

installing into c:\ado\plus\...
installation complete.

. 
. *****************
. * Load US data  *
. *****************
. use "BSG & Yakter PSRM - US survey-experiment data", replace

. 
. *****************************************************
. * Influence of action type - by ideology (Figure 6) *
. *****************************************************
. * binary action - hetereognous effects, predicted value graphs
. grstyle init

. grstyle set legend, nobox

. grstyle set plain, nogrid box

. qui reg is_terror i.tr_nonviolence##i.ideology_lean i.attention

. margins, at(ideology_lean=(1(1)3) tr_nonviolence=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_nonviolence = 0
       ideology_lean  = 1
2._at: tr_nonviolence = 0
       ideology_lean  = 2
3._at: tr_nonviolence = 0
       ideology_lean  = 3
4._at: tr_nonviolence = 1
       ideology_lean  = 1
5._at: tr_nonviolence = 1
       ideology_lean  = 2
6._at: tr_nonviolence = 1
       ideology_lean  = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   7.490312   .2746892    27.27   0.000     6.951303    8.029321
          2  |   8.754241   .4975703    17.59   0.000     7.777884    9.730598
          3  |   8.199298   .2507633    32.70   0.000     7.707237    8.691358
          4  |   3.462914    .160799    21.54   0.000     3.147386    3.778441
          5  |   2.851702     .31677     9.00   0.000      2.23012    3.473284
          6  |   4.659625   .1412922    32.98   0.000     4.382374    4.936876
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "Violence" 4 "Non-violence" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         title("Denotation", size(large)) ///
>         name(terror_violence_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_nonviolence
(note:  named style gr6 not found in class color, default attributes used)

. qui reg is_illegitimate i.tr_nonviolence##i.ideology_lean i.attention 

. margins, at(ideology_lean=(1(1)3) tr_nonviolence=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_nonviolence = 0
       ideology_lean  = 1
2._at: tr_nonviolence = 0
       ideology_lean  = 2
3._at: tr_nonviolence = 0
       ideology_lean  = 3
4._at: tr_nonviolence = 1
       ideology_lean  = 1
5._at: tr_nonviolence = 1
       ideology_lean  = 2
6._at: tr_nonviolence = 1
       ideology_lean  = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   8.760803   .2818466    31.08   0.000     8.207749    9.313856
          2  |   9.125949   .5105351    17.88   0.000     8.124151    10.12775
          3  |   8.665089   .2572973    33.68   0.000     8.160208    9.169971
          4  |   5.209667   .1649888    31.58   0.000     4.885918    5.533417
          5  |   4.995142   .3250238    15.37   0.000     4.357364     5.63292
          6  |   6.678338   .1449738    46.07   0.000     6.393863    6.962812
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "Violence" 4 "Non-violence" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         title("Illegitimacy", size(large)) ///
>         name(legitimate_violence_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_nonviolence
(note:  named style gr6 not found in class color, default attributes used)

. qui reg use_force i.tr_nonviolence##i.ideology_lean i.attention

. margins, at(ideology_lean=(1(1)3) tr_nonviolence=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_nonviolence = 0
       ideology_lean  = 1
2._at: tr_nonviolence = 0
       ideology_lean  = 2
3._at: tr_nonviolence = 0
       ideology_lean  = 3
4._at: tr_nonviolence = 1
       ideology_lean  = 1
5._at: tr_nonviolence = 1
       ideology_lean  = 2
6._at: tr_nonviolence = 1
       ideology_lean  = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   6.835659   .2767857    24.70   0.000     6.292536    7.378781
          2  |   8.502098   .5013678    16.96   0.000     7.518289    9.485906
          3  |   8.329846   .2526772    32.97   0.000      7.83403    8.825661
          4  |   3.130372   .1620262    19.32   0.000     2.812436    3.448308
          5  |   3.419639   .3191876    10.71   0.000     2.793313    4.045965
          6  |   4.688797   .1423706    32.93   0.000      4.40943    4.968164
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "Violence" 4 "Non-violence" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         title("Use of Force", size(large)) ///
>         name(force_violence_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_nonviolence
(note:  named style gr6 not found in class color, default attributes used)

. grc1leg2 terror_violence_pv legitimate_violence_pv force_violence_pv ///
>         , rows(1) xcommon ycommon labsize(small) ///
>         b2title("Ideology", size(medsmall)) ///
>         l1title("Predicted Values",  size(medsmall)) ring(2) ///
>         xsize(6) ysize(3) scale(1.4) ///
>         name(combine_violence, replace)
-grc1leg2- working...
(note:  named style gr6 not found in class color, default attributes used)
(note:  named style gr6 not found in class color, default attributes used)
(note:  named style gr6 not found in class color, default attributes used)

. graph export Figure6.pdf
file Figure6.pdf saved as PDF format

. 
. **************************************************
. * Influence of labeling - by ideology (Figure 7) *
. **************************************************
. qui reg is_terror i.tr_frame##i.ideology_lean i.attention 

. margins, at(ideology_lean=(1(1)3) tr_frame=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_frame      = 0
       ideology_lean = 1
2._at: tr_frame      = 0
       ideology_lean = 2
3._at: tr_frame      = 0
       ideology_lean = 3
4._at: tr_frame      = 1
       ideology_lean = 1
5._at: tr_frame      = 1
       ideology_lean = 2
6._at: tr_frame      = 1
       ideology_lean = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   4.045919   .2316455    17.47   0.000     3.591372    4.500465
          2  |   3.814251   .4291959     8.89   0.000     2.972062    4.656441
          3  |   5.201939   .2017629    25.78   0.000      4.80603    5.597849
          4  |   4.919894   .2280392    21.57   0.000     4.472424    5.367364
          5  |   5.392008   .4573581    11.79   0.000     4.494557    6.289459
          6  |   5.836241   .2061004    28.32   0.000      5.43182    6.240661
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "No Label" 4 "Terror Label" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         legend(label(1 "No Label" 2 "Terror Label")) ///
>         title("Denotation", size(large)) ///
>         name(terror_label_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_frame
(note:  named style gr6 not found in class color, default attributes used)

. qui reg is_illegitimate i.tr_frame##i.ideology_lean i.attention

. margins, at(ideology_lean=(1(1)3) tr_frame=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_frame      = 0
       ideology_lean = 1
2._at: tr_frame      = 0
       ideology_lean = 2
3._at: tr_frame      = 0
       ideology_lean = 3
4._at: tr_frame      = 1
       ideology_lean = 1
5._at: tr_frame      = 1
       ideology_lean = 2
6._at: tr_frame      = 1
       ideology_lean = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   5.863848   .2218624    26.43   0.000     5.428498    6.299197
          2  |   5.678143   .4110698    13.81   0.000     4.871522    6.484765
          3  |   7.092596   .1932419    36.70   0.000     6.713407    7.471785
          4  |   6.359167   .2184084    29.12   0.000     5.930595    6.787739
          5  |   6.761284   .4380426    15.44   0.000     5.901735    7.620833
          6  |   7.223643   .1973962    36.59   0.000     6.836302    7.610983
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "No Label" 4 "Terror Label" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         title("Illegitimacy", size(large)) ///
>         name(legitimate_label_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_frame
(note:  named style gr6 not found in class color, default attributes used)

. qui reg use_force i.tr_frame##i.ideology_lean i.attention

. margins, at(ideology_lean=(1(1)3) tr_frame=(0 1))

Predictive margins                                       Number of obs = 1,046
Model VCE: OLS

Expression: Linear prediction, predict()
1._at: tr_frame      = 0
       ideology_lean = 1
2._at: tr_frame      = 0
       ideology_lean = 2
3._at: tr_frame      = 0
       ideology_lean = 3
4._at: tr_frame      = 1
       ideology_lean = 1
5._at: tr_frame      = 1
       ideology_lean = 2
6._at: tr_frame      = 1
       ideology_lean = 3

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         _at |
          1  |   3.999118   .2309294    17.32   0.000     3.545977    4.452259
          2  |   4.186808   .4278691     9.79   0.000     3.347221    5.026394
          3  |    5.51096   .2011392    27.40   0.000     5.116275    5.905645
          4  |   4.148979   .2273342    18.25   0.000     3.702893    4.595066
          5  |   5.675837   .4559443    12.45   0.000     4.781161    6.570514
          6  |   5.622855   .2054633    27.37   0.000     5.219684    6.026025
------------------------------------------------------------------------------

. mplotoffset, recast(scatter) ///
>         plot1opts(mcolor(black)) ci1opts(lcolor(black)) ///
>         plot2opts(mcolor(black) msymbol(Oh)) ci2opts(lcolor(black)) ///
>         legend(order(3 "No Label" 4 "Terror Label" )) ///
>         yscale(range(2 10)) ylabel(2(2)10, labsize(medsmall)) ///
>         xlabel(1 "Liberal" 2 "Neither" 3 "Cons.", labsize(medsmall)) ///
>         ytitle("")      xtitle("")  ///
>         yline(5.5, lpattern(dash) lcolor(gr6)) ///
>         title("Use of Force", size(large)) ///
>         name(force_label_pv, replace)

  Variables that uniquely identify margins: ideology_lean tr_frame
(note:  named style gr6 not found in class color, default attributes used)

. grc1leg2 terror_label_pv legitimate_label_pv force_label_pv ///
>         , rows(1) xcommon ycommon labsize(small) ///
>         b2title("Ideology", size(medsmall)) ///
>         l1title("Predicted Values",  size(medsmall)) ring(2) ///
>         xsize(6) ysize(3) scale(1.4) ///
>         name(combine_label, replace)
-grc1leg2- working...
(note:  named style gr6 not found in class color, default attributes used)
(note:  named style gr6 not found in class color, default attributes used)
(note:  named style gr6 not found in class color, default attributes used)

. graph export Figure7.pdf
file Figure7.pdf saved as PDF format

. 
.         
. *******************************************
. * Appendix: Sample tests and descriptives *
. *******************************************
. * balance tests by demography (Table B2)
. ****************************************
. eststo clear

. qui eststo: mlogit treatment_group i.sex i.agegr i.race i.edu i.ideology_lean ib1.attention, b(4)

. esttab using TableB2.rtf, ///
>         b(3) unstack nogaps noomitted not label noobs drop(1* 0*)
(output written to TableB2.rtf)

. 
. * power analysis (scores used for Table B3)
. *******************************************
. retrodesign 0.3 0.5 1 1.5, se(0.2) alpha(0.05) df(135)

      Effect |     Power    S-error    M-error 
-------------+---------------------------------
         0.3 |    0.3172     0.0011     1.7614 
         0.5 |    0.6989     0.0000     1.1977 
           1 |    0.9985     0.0000     1.0040 
         1.5 |    1.0000     0.0000     1.0022 
-----------------------------------------------

Note:
- Power is the probability that the statistical test correctly rejects the null hypothesis.
- Type-S (sign) error is the probability of the sign being in the opposite direction of the effect size.
- Type-M (magnitude) error is the factor by which the magnitude of the effect size might be exaggerated.

. 
. * descriptive stats 
. *******************
. * summary for table (scores used for Table C2)
. summarize is_terror is_illegitimate use_force i.ideology_lean attention if is_terror!=.

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
   is_terror |      1,135    4.984141    3.355444          1         10
is_illegit~e |      1,135    6.662555     3.19139          1         10
   use_force |      1,135    4.940969    3.365591          1         10
             |
ideology_l~n |
    Liberal  |      1,046    .3938815    .4888428          0          1
    Neither  |      1,046    .1061185    .3081366          0          1
-------------+---------------------------------------------------------
Conservat~e  |      1,046          .5    .5002392          0          1
             |
   attention |      1,135    .9656388    .1822356          0          1

. * distribution graphs (Figure C2)
. graph bar (percent), ///
>         over(is_terror, gap(*0.5) nolab) ///
>         bar(1 ,color(black)) ytitle("Percent") ylabel(,nogrid) ///
>         title("Denotation") name(is_terror_bar, replace)

. graph bar (percent), ///
>         over(is_illegitimate, gap(*0.5) nolab) ///
>         bar(1 ,color(black)) ytitle("Percent") ylabel(,nogrid) ///
>         title("Illegitimacy") name(is_illegitimate_bar, replace)

. graph bar (percent), ///
>         over(use_force, gap(*0.5) nolab) ///
>         bar(1 ,color(black)) ytitle("Percent") ylabel(,nogrid) ///
>         title("Use of Force") name(use_force_bar, replace)

. graph bar (percent), ///
>         over(ideology_lean, gap(*0.5) relabel(1 "Liberal" 2 "Neither" 3 "Conserv.")) ///
>         bar(1 ,color(black)) ytitle("Percent") ylabel(,nogrid) ///
>         title("Vote by Partisan Bloc") name(vote_bloc_rcl_bar, replace)

. graph bar (percent), ///
>         over(attention, gap(*0.5) relabel(1 "Failed"  2 "Passed")) ///
>         bar(1 ,color(black)) ytitle("Percent") ylabel(,nogrid) ///
>         title("Attention Check") name(attention_bar, replace)

. graph combine is_terror_bar is_illegitimate_bar use_force_bar vote_bloc_rcl_bar attention_bar, ///
>         col(3) ycommon

. graph export FigureC2.pdf
file FigureC2.pdf saved as PDF format

. 
. 
. ***************************************
. * Appendix: full models behind graphs *
. ***************************************
. * violence vs nonviolence interacted with partisanship (Table D5)
. eststo clear

. qui eststo: reg is_terror i.tr_nonviolence##i.ideology_lean attention

. qui eststo: reg is_illegitimate i.tr_nonviolence##i.ideology_lean attention

. qui eststo: reg use_force i.tr_nonviolence##i.ideology_lean attention

. esttab using TableD5.rtf, ///
>         b(3) se(3) r2(3) nogaps compress ///
>         drop(1.ideology_lean 1.tr_nonviolence#1.ideology_lean 0*) ///
>         star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
>         order(_cons 1.tr_nonviolence 2.ideology_lean 3.ideology_lean 1.tr_nonviolence#2.ideology_lean ///
>                 1.tr_nonviolence#3.ideology_lean attention) ///
>         coeflabels(1.tr_nonviolence Non-violence 2.ideology_lean Neither 3.ideology_lean Right ///
>                 1.tr_nonviolence#2.ideology_lean Non-violenceXNeither 1.tr_nonviolence#3.ideology_lean ///
>                 Non-violenceXConservative attention Attention _cons Constant-Violence-Liberal) ///
>         mtitles("Terror Denotation" "Illegitimacy" "Use Force") 
(output written to TableD5.rtf)

. 
. * terror label interacted with partisanship (Table D6)
. eststo clear

. qui eststo: reg is_terror i.tr_frame##i.ideology_lean attention

. qui eststo: reg is_illegitimate i.tr_frame##i.ideology_lean attention 

. qui eststo: reg use_force i.tr_frame##i.ideology_lean attention 

. esttab using TableD6.rtf, ///
>         b(3) se(3) r2(3) nogaps compress ///
>         drop(1.ideology_lean 1.tr_frame#1.ideology_lean 0*) ///
>         star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
>         order(_cons 1.tr_frame 2.ideology_lean 3.ideology_lean 1.tr_frame#2.ideology_lean ///
>                 1.tr_frame#3.ideology_lean attention) ///
>         coeflabels(1.tr_frame Terror_Label 2.ideology_lean Neither 3.ideology_lean Right ///
>                 1.tr_frame#2.ideology_lean Terror_LabelXNeither 1.tr_frame#3.ideology_lean ///
>                 Terror_LabelXConservative attention Attention _cons Constant-No_Label-Liberal) ///
>         mtitles("Terror Denotation" "Illegitimacy" "Use Force") 
(output written to TableD6.rtf)

. 
. 
end of do-file

. log close
      name:  <unnamed>
       log:  C:\Users\alony\Dropbox\Alon\@ Research projects @\Peace process opinion\Perceptions of terrorism (with Avishay BSG)\Submissions\2022
> .09 PSRM (accepted)\2023.04 Final version\Data replication files\Replication log - Stata - US.log
  log type:  text
 closed on:  22 May 2023, 00:19:36
-------------------------------------------------------------------------------------------------------------------------------------------------
